﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using MvcKO.ViewModels;

namespace MvcKO.Controllers
{
    public class ExamplesController : Controller
    {
        public ActionResult Foreach()
        {
            People viewModel = new People();
            viewModel.people.Add(new Person() { firstName = "Bert", lastName = "Bertington" });
            viewModel.people.Add(new Person() { firstName = "Charles", lastName = "Charlesforth" });
            viewModel.people.Add(new Person() { firstName = "Denise", lastName = "Dentiste" });

            return View(viewModel);
        }

        public ActionResult If()
        {
            MessageModel viewModel = new MessageModel();
            return View(viewModel);
        }

        public ActionResult Ifnot()
        {
            MessageModel viewModel = new MessageModel();
            return View(viewModel);
        }

        public ActionResult With()
        {
            Location viewModel = new Location()
                        {
                            City = "New York",
                            Coords = new Coords() 
                                            {
                                                Latitude = 40.75558,
                                                Longitude = -73.991547,
                                            }
                        };

            return View(viewModel);
        }

        public ActionResult Templates()
        {
            BuyerSeller viewModel = new BuyerSeller()
                                            {
                                                Buyer = new Account()
                                                                {
                                                                    Credits = 250,
                                                                    Name = "Franklin",
                                                                },
                                                Seller = new Account() 
                                                                {
                                                                    Credits = 5800,
                                                                    Name = "Mario",
                                                                },
                                                Accounts = new List<Account>(),
                                            };

            viewModel.Accounts.Add(new Account(){ Credits = 134, Name = "Jim" });
            viewModel.Accounts.Add(new Account() { Credits = 566, Name = "Peter" });
            viewModel.Accounts.Add(new Account() { Credits = 218, Name = "Mary" });

            return View(viewModel);
        }

        public ActionResult FileNames()
        {
            return View();
        }

        public ActionResult CodeGeneration()
        {
            return View();
        }

        public ActionResult ViewModels()
        {
            return View();
        }

        public ActionResult Controllers()
        {
            return View();
        }

        public ActionResult Computed()
        {
            ComputedModel vewModel = new ComputedModel() 
                                            {
                                                 FirstName = "Bob",
                                                 LastName = "Smith"
                                            };
            return View(vewModel);
        }

        public ActionResult Visible()
        {
            VisibilityModel viewModel = new VisibilityModel() 
                                {
                                    MyValues = new string[] {"first", "second", "thrid"},
                                    ShouldShowMessage = true,
                                };
            return View(viewModel);
        }

        public ActionResult Text()
        {
            TextModel viewModel = new TextModel() 
                                          {
                                              MyMessage = "Hello World!",
                                              Price = 24.95,
                                          };

            return View(viewModel);
        }

        public ActionResult Html()
        {
            HtmlModel viewModel = new HtmlModel();

            viewModel.Details = "<em>For further details, view the report <a href='#'>here</a>.</em>";

            return View(viewModel);
        }

        public ActionResult CSS()
        {
            ProfitModel viewModel = new ProfitModel() 
                                            {
                                                Profit = 9.45
                                            };
            return View(viewModel);
        }

        public ActionResult Style()
        {
            ProfitModel viewModel = new ProfitModel()
            {
                Profit = 9.45
            };
            return View(viewModel);
        }

        public ActionResult Attr()
        {
            AttrModel viewModel = new AttrModel() 
                                            {
                                                ImageLocation = Url.Content("~/content/images/icon-leaf.png"),
                                                ImageTitle = "this is a title",
                                            };
            return View(viewModel);
        }

        public ActionResult Value()
        {
            LoginModel viewModel = new LoginModel() 
                                            {
                                                UserPassword = "abc"
                                            };
            return View(viewModel);
        }

        public ActionResult Options()
        {
            CountriesModel viewModel = new CountriesModel()
                                            {
                                                AvailableCountries = new string[] { "France", "Germany", "Spain" },
                                                AvailableCountries2 = new List<Country>()
                                            };

            viewModel.AvailableCountries2.Add(new Country(){ CountryName = "UK", CountryPopulation = 65000000});
            viewModel.AvailableCountries2.Add(new Country(){ CountryName = "USA", CountryPopulation = 320000000});
            viewModel.AvailableCountries2.Add(new Country(){ CountryName = "Sweden", CountryPopulation = 29000000 });

            return View(viewModel);
        }

        public ActionResult SelectedOptions()
        {
            CountriesModel viewModel = new CountriesModel()
            {
                AvailableCountries = new string[] { "France", "Germany", "Spain" },
                AvailableCountries2 = new List<Country>()
            };

            viewModel.AvailableCountries2.Add(new Country() { CountryName = "UK", CountryPopulation = 65000000 });
            viewModel.AvailableCountries2.Add(new Country() { CountryName = "USA", CountryPopulation = 320000000 });
            viewModel.AvailableCountries2.Add(new Country() { CountryName = "Sweden", CountryPopulation = 29000000 });

            return View(viewModel);
        }

        public ActionResult Autocomplete()
        {
            return View();
        }

        public ActionResult Enable()
        {
            CellPhoneModel cellphoneModel = new CellPhoneModel();

            return View(cellphoneModel);
        }

        public ActionResult Disable()
        {
            CellPhoneModel cellphoneModel = new CellPhoneModel();

            return View(cellphoneModel);
        }

        public ActionResult CustomControls()
        {
            return View();
        }

        public ActionResult Helper()
        {
            return View();
        }

        public ActionResult QuickIntro()
        {
            return View();
        }

        public ActionResult Checked()
        {
            SpamModel viewModel = new SpamModel()
                                        {
                                            WantsSpam = true,
                                            SpamFlavors = new string[] { "almond", "msg" }
                                        };
            return View(viewModel);
        }        
    }
}
